package com.tancire.web.controller.works;

import java.util.List;
import javax.annotation.Resource;
import javax.servlet.http.HttpServletResponse;
import org.springframework.security.access.prepost.PreAuthorize;
import org.springframework.web.bind.annotation.GetMapping;
import org.springframework.web.bind.annotation.PostMapping;
import org.springframework.web.bind.annotation.PutMapping;
import org.springframework.web.bind.annotation.DeleteMapping;
import org.springframework.web.bind.annotation.PathVariable;
import org.springframework.web.bind.annotation.RequestBody;
import org.springframework.web.bind.annotation.RequestMapping;
import org.springframework.web.bind.annotation.RestController;
import com.tancire.common.annotation.Log;
import com.tancire.common.core.controller.BaseController;
import com.tancire.common.core.domain.AjaxResult;
import com.tancire.common.enums.BusinessType;
import com.tancire.works.domain.SideWorkEnroll;
import com.tancire.works.service.ISideWorkEnrollService;
import com.tancire.common.utils.poi.ExcelUtil;
import com.tancire.common.core.page.TableDataInfo;

/**
 * 兼职报名Controller
 *
 * @author tancire
 * @date 2024-03-11
 */
@RestController
@RequestMapping("/works/sideWorkEnroll")
public class SideWorkEnrollController extends BaseController {
    @Resource
    private ISideWorkEnrollService sideWorkEnrollService;

    /**
     * 查询兼职报名列表
     */
    @PreAuthorize("@ss.hasPermi('works:sideWorkEnroll:list')")
    @GetMapping("/list")
    public TableDataInfo list(SideWorkEnroll sideWorkEnroll) {
        startPage();
        List<SideWorkEnroll> list = sideWorkEnrollService.selectSideWorkEnrollList(sideWorkEnroll);
        return getDataTable(list);
    }

    /**
     * 导出兼职报名列表
     */
    @PreAuthorize("@ss.hasPermi('works:sideWorkEnroll:export')")
    @Log(title = "兼职报名", businessType = BusinessType.EXPORT)
    @PostMapping("/export")
    public void export(HttpServletResponse response, SideWorkEnroll sideWorkEnroll) {
        List<SideWorkEnroll> list = sideWorkEnrollService.selectSideWorkEnrollList(sideWorkEnroll);
        ExcelUtil<SideWorkEnroll> util = new ExcelUtil<SideWorkEnroll>(SideWorkEnroll.class);
        util.exportExcel(response, list, "兼职报名数据");
    }

    /**
     * 获取兼职报名详细信息
     */
    @PreAuthorize("@ss.hasPermi('works:sideWorkEnroll:query')")
    @GetMapping(value = "/{id}")
    public AjaxResult getInfo(@PathVariable("id") Long id) {
        return AjaxResult.success(sideWorkEnrollService.selectSideWorkEnrollById(id));
    }

    /**
     * 新增兼职报名
     */
    @PreAuthorize("@ss.hasPermi('works:sideWorkEnroll:add')")
    @Log(title = "兼职报名", businessType = BusinessType.INSERT)
    @PostMapping
    public AjaxResult add(@RequestBody SideWorkEnroll sideWorkEnroll) {
        return toAjax(sideWorkEnrollService.insertSideWorkEnroll(sideWorkEnroll));
    }

    /**
     * 修改兼职报名
     */
    @PreAuthorize("@ss.hasPermi('works:sideWorkEnroll:edit')")
    @Log(title = "兼职报名", businessType = BusinessType.UPDATE)
    @PutMapping
    public AjaxResult edit(@RequestBody SideWorkEnroll sideWorkEnroll) {
        return toAjax(sideWorkEnrollService.updateSideWorkEnroll(sideWorkEnroll));
    }

    /**
     * 删除兼职报名
     */
    @PreAuthorize("@ss.hasPermi('works:sideWorkEnroll:remove')")
    @Log(title = "兼职报名", businessType = BusinessType.DELETE)
	@DeleteMapping("/{ids}")
    public AjaxResult remove(@PathVariable Long[] ids) {
        return toAjax(sideWorkEnrollService.deleteSideWorkEnrollByIds(ids));
    }
}
